//类描述 处理窗体
Ext.define("SHApp.ClientInfo.BagManage.Form", {
    extend: "BLBTSystem.Form",
    submitUrl: "api/bagmanage?format=json",
    winWidth: 665,
    contractCmb: null,
    winHeight: 200,
    CodeID: "_codeID",
    StartDateID: "_start",
    CompanyNameID: "_companyID",
    ContractID: "_contractID",
    EndDateID: "_end",
    CompanyIdID: "_company",
    txtCode: null,
    txtStartDate: null,
    txtCompanyName: null,
    txtContract: null,
    txtEndDate: null,
    txtCompanyId: null,
    initComponent: function () {
        var me = this;
        me.CodeID += me.id;
        me.CompanyIdID += me.id;
        me.CompanyNameID += me.id;
        me.ContractID += me.id;
        me.EndDateID += me.id;
        me.StartDateID += me.id;

        Ext.apply(this);

        me.contractCmb = Ext.create('SHApp.ClientInfo.BagManage.ContractComboBox', {
            fieldLabel: "合同名称",
            name: 'ContractCode'
        });
        this.createItems();
        this.callParent(arguments);

        me.txtCode = Ext.getCmp(me.CodeID);
        me.txtCompanyId = Ext.getCmp(me.CompanyIdID);
        me.txtCompanyName = Ext.getCmp(me.CompanyNameID);
        me.txtContract = Ext.getCmp(me.ContractID);
        me.txtEndDate = Ext.getCmp(me.EndDateID);
        me.txtStartDate = Ext.getCmp(me.StartDateID);

        me.contractCmb.on("select", function (c, r, o) {
            if (r && r.length > 0) {
                //me.txtCode.setValue(r[0].data.Code);
                me.txtCompanyId.setValue(r[0].data.CompanyID);
                me.txtCompanyName.setValue(r[0].data.CompanyName);
                me.txtContract.setValue(r[0].data.Name);
                me.txtEndDate.setValue(formatDate(r[0].data.EndDateTime));
                me.txtStartDate.setValue(formatDate(r[0].data.StartDateTime));
            }
        })
    },
    createItems: function () {
        var me = this;
        this.items = [{
            width: 300,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [
				{
				    xtype: "textfield",
				    fieldLabel: "ID",
				    name: "Id",
				    hidden: true
				}, {
				    fieldLabel: "<span style='color:red'>*</span>编号",
				    allowBlank: false,
				    blankText: "请输入编号!",
				    xtype: "textfield",
				    name: "Code",
				    maxLength: 50
				}, me.contractCmb
            , {
                fieldLabel: "企业名称",
                xtype: "textfield",
                name: "CompanyName",
                maxLength: 50,
                id: me.CompanyNameID,
                readOnly: true
            }]
        }, {
            width: 300,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [{
                fieldLabel: "<span style='color:red'>*</span>名称",
                allowBlank: false,
                blankText: "请输入名称!",
                xtype: "textfield",
                name: "Name",
                maxLength: 50
            },
                {
                    fieldLabel: "合同名称",
                    xtype: "textfield",
                    name: "ContractName",
                    maxLength: 50,
                    id: me.ContractID,
                    hidden: true
                },
                {
                    xtype: "datefield",
                    fieldLabel: "签订日期",
                    value: new Date(),
                    name: "StartDateTime",
                    format: 'Y-m-d',
                    id: me.StartDateID,
                    readOnly: true
                },
             {
                 xtype: "datefield",
                 fieldLabel: "截止日期",
                 value: new Date(),
                 name: "EndDateTime",
                 format: 'Y-m-d',
                 id: me.EndDateID,
                 readOnly: true
             }, {
                 fieldLabel: "企业ID",
                 xtype: "textfield",
                 name: "CompanyID",
                 maxLength: 50,
                 id: me.CompanyIdID,
                 hidden: true
             }]
        }
		];
    }
})